package com.drivingtheproject.wifie.wifiexpert;

import android.app.Activity;
import android.app.ActionBar;
import android.app.Fragment;
import android.content.ContentResolver;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.os.Build;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

import com.drivingtheproject.wifie.com.drivingtheproject.wifie.common.Constants;
import com.drivingtheproject.wifie.data.DatabaseHandler;
import com.drivingtheproject.wifie.data.Profile;

import java.util.ArrayList;
import java.util.List;

import static android.content.ContentResolver.*;


public class MainActivity extends BaseActivity  {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        DatabaseHandler databaseHandler = new DatabaseHandler(this);

        final ArrayList<Profile> contacts = new ArrayList<Profile>();
        contacts.add(new Profile("Sap_Internet"));
        contacts.add(new Profile("Home_Internet"));
        final ListView listview = (ListView) findViewById(R.id.listViewProfiles);

        final ProfilesAdapter adapter = new ProfilesAdapter(this, contacts);
        listview.setAdapter(adapter);
        listview.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

            public boolean onItemLongClick(AdapterView<?> arg0, View v,
                                           int index, long arg3) {

                Intent myIntent = new Intent(MainActivity.this, ProfileActivity.class);
                myIntent.putExtra(Constants.SELECTED_PROFILE, adapter.getItem(index)); //Optional parameters
                startActivity(myIntent);
                return false;
            }
        });

    }
}
